class_name Character
extends CharacterBody2D



@export var friction: int = 0
@export var speed: int = 0
@export var size: Vector2 = Vector2(60, 60):
    set(value):
        size = value
        queue_redraw()

@export var color: Color = Color.RED:
    set(value):
        color = value
        queue_redraw()

@export var max_health: int = 500:
    set(value):
        value = clamp(value, 0, 999999)
        if value != max_health:
            max_health = value
            max_health_changed.emit()

@export var health: int = 500:
    set(value):
        value = clamp(value, 0, max_health)
        if value != health:
            health = value
            health_changed.emit()
            if value == 0:
                died.emit()


signal died
signal health_changed
signal max_health_changed


func _draw() -> void:
    draw_rect(Rect2(Vector2.ZERO - size / 2, size), color)


